#-*-coding:utf-8-*-

import sys
import time
import math
import json
import random
from PIL import Image
import os
# train_nots ="./train_notsplit"
# train_splite ="./train"
train_nots ="./test_notsplit"
train_splite ="./test"
for dir in os.listdir(train_nots):
    image_file =os.path.join(train_nots,dir)
    img = Image.open(image_file)
    s = str(dir).split('.')[0]
    p_number,content = s.split('-')
    region = [(0,0,20,26),(16,0,38,26),(34,0,56,26),(52,0,74,26)]

    for i in range(0,len(region)):
		cropImg = img.crop(region[i])
		path = train_splite+'/'+p_number+'-'+str(i)+'-'+content[i]+'.jpg'
		print path
		cropImg.save(path)
for dir in os.listdir(train_nots):
    image_file =os.path.join(train_nots,dir)
    img = Image.open(image_file)
    s = str(dir).split('.')[0]
    p_number,content = s.split('-')
    region = [(0,0,20,26),(16,0,38,26),(34,0,56,26),(52,0,74,26)]

    for i in range(0,len(region)):
		cropImg = img.crop(region[i])
		path = train_splite+'/'+p_number+'-'+str(i)+'-'+content[i]+'.jpg'
		print path
		cropImg.save(path)
